import service from "../api/request"
// // 前端 request.js 全局配置
// service.interceptors.request.use(config => {
//   if (config.method === 'post') {
//     config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
//     // 如果必须用 JSON
//     // config.headers['Access-Control-Allow-Origin'] = '*'
//   }
//   return config
// })

export const getEmailCode = (transfer) => {
  return service.get('/bestpaygo-user/captcha/email/codeSend', {
    params: {
      email: transfer
    }
  })
}
export const getCaptchaCode = () => {
  return service.get('/bestpaygo-user/captcha/password/graphic', {
    params: {}
  })
}
export function getLogin(transfer) {
  return service({
    url: "/bestpaygo-user/login",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const exitLogin = () => {
  return service({
    url: "/bestpaygo-user/logout",
    method: "post",
    data: {},
  })
}

export const getUserBasicData = () => {
  return service.get('/bestpaygo-user/loginUserDetails', {
    params: {}
  })
}

export const getMoveRouter = () => {
  return service.get('/bestpaygo-user/v1/menu/treeselect', {
    params: {}
  })
}

export const getAdmindata = (pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/adminPageUsers', {
    params: {
      pageNum,pageSize
    }
  })
}
export const getAdmindatalike = (nickname, communication, lockState, enableStatus,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/adminPageUsers', {
    params: {
      nickname,
      communication,
      lockState,
      enableStatus,
      pageNum,
      pageSize
    }
  })
}
export function updateadmin(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/adminEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export const deladmin = (userId) => {
    return service({
      url: "/bestpaygo-user/v1/user/adminRemove",
      method: "post",
      data: {
        userId
      },
    headers: {
      'Content-Type': 'application/json'
    }
    })

}
export function adminResetPassword(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/adminResetPassword",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function AddAdminData(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/adminInsert",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}


export function editaccountNonLocked(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/adminEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getSupplierdata = (pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/distributorPageUsers', {
    params: {pageNum,pageSize}
  })
}
export const getSupplierdataChu = (pageNum,pageSize,queryType) => {
  return service.get('/bestpaygo-user/v1/user/distributorPageUsers', {
    params: {pageNum,pageSize,queryType}
  })
}

export const distributorDropDownapi = () => {
  return service.get('/bestpaygo-user/v1/user/distributorDropDown', {
    params: {}
  })
}
export const getSupplierlike = (nickname, communication, lockState, enableStatus,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/distributorPageUsers', {
    params: {
      nickname,
      communication,
      lockState,
      enableStatus,
      pageNum,
      pageSize
    }
  })
}

export function AddSupplierData(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/distributorInsert",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function updateSupplier(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/distributorEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const delSupplier = (userId) => {
    return service({
      url: "/bestpaygo-user/v1/user/distributorRemove",
      method: "post",
      data: {
        userId
      },
    headers: {
      'Content-Type': 'application/json'
    }
    })

}

export function SupplierResetPassword(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/distributorResetPassword",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function editSupplieraccountNonLocked(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/distributorEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export const getEndUserData = (pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/endPageUsers', {
    params: {
      pageNum,pageSize
    }
  })
}

export const getEndUserdatalike = (nickname, communication, lockState, enableStatus,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/endPageUsers', {
    params: {
      nickname,
      communication,
      lockState,
      enableStatus,
      pageNum,pageSize
    }
  })
}
export function AddEndUserData(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/endInsert",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function updateaEndUser(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/endEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const delEndUser = (userId) => {
    return service({
      url: "/bestpaygo-user/v1/user/endRemove",
      method: "post",
      data: {
        userId
      },
    headers: {
      'Content-Type': 'application/json'
    }
    })

}

export function EndUserResetPassword(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/endResetPassword",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function editaccountNonLockedEndUser(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/endEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}


export const getAgentdata = (pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/userGroup/pageUserGroups', {
    params: {
      pageNum,pageSize
    }
  })
}
export const getgrouptoList = (originAdminId) => {
  return service.get('/bestpaygo-user/v1/userGroup/userGroupsDropDown', {
    params: {
      originAdminId
    }
  })
}
export const getAddGroupList = (originAdminId,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/userGroup/pageUserGroupMembers', {
    params: {
      originAdminId,pageNum,pageSize
    }
  })
}

export function memberMigration(transfer) {
  return service({
    url: "/bestpaygo-user/v1/userGroup/memberMigration",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export const getsuppList = () => {
  return service.get('/bestpaygo-user/v1/user/distributorDropDown', {
    params: {}
  })
}
export const getMenuList = () => {
  return service.get('/bestpaygo-user/v1/menu/list', {
    params: {}
  })
}
export const getMenudatalike = (val) => {
  return service.get('/bestpaygo-user/v1/menu/list', {
    params: {
      menuName: val
    }
  })
}

export const addMenuapi = (menuName, perms, icon, parentId, orderNum, path, component, menuType) => {
  // console.log(val);s

  console.log(menuName, perms, icon, parentId, orderNum, path, component, menuType);
  if (icon == "", path == "", component == "") {
    return service({
      url: "/bestpaygo-user/v1/menu/add",
      method: "post",
      data: {
        menuName, perms, parentId, orderNum, menuType
      },
    })
  } else {
    return service({
      url: "/bestpaygo-user/v1/menu/add",
      method: "post",
      data: {
        menuName, perms, icon, parentId, orderNum, path, component, menuType
      },
    })
  }

}
export const EditMenuapi = (menuId,menuName, perms, icon, parentId, orderNum, path, component, menuType) => {
  // console.log(val);s

  console.log(menuId,menuName, perms, icon, parentId, orderNum, path, component, menuType);
  if (icon == "", path == "", component == "") {
    return service({
      url: "/bestpaygo-user/v1/menu/edit",
      method: "post",
      data: {
        menuId,menuName, perms, parentId, orderNum, menuType
      },
    })
  } else {
    return service({
      url: "/bestpaygo-user/v1/menu/add",
      method: "post",
      data: {
        menuId,menuName, perms, icon, parentId, orderNum, path, component, menuType
      },
    })
  }

}

export const delMenuapi = (menuId) => {
    return service({
      url: "/bestpaygo-user/v1/menu/remove",
      method: "post",
      data: {
       menuId
      },
    })

}

export const personcenterEditInfo = ({nickname,gender,area,address}) => {
    return service({
      url: "/bestpaygo-user/v1/user/edit",
      method: "post",
      data: {
      nickname,gender,area,address
      },
    })

}
export function personcenterEditPass(transfer) {
  return service({
    url: "/bestpaygo-user/v1/user/resetPassword",
    method: "post",
    data: { security: transfer },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getRoledata = (pageNum, pageSize) => {
  return service.get('/bestpaygo-user/v1/role/pageRoles', {
    params: {
      pageNum, pageSize
    }
  })
}
export const getRoledataList= () => {
  return service.get('/bestpaygo-user/v1/role/dropDown', {
    params: {
     
    }
  })
}

export const getRolelike = (val,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/role/pageRoles', {
    params: {
      roleNameOrCode: val,
      pageNum,pageSize
    }
  })
}

export function addRoleData(transfer) {
  return service({
    url: "/bestpaygo-user/v1/role/add",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export const delRole = (roleId) => {
     return service({
      url: "/bestpaygo-user/v1/role/remove",
      method: "post",
      data: {
        roleId
      },
    headers: {
      'Content-Type': 'application/json'
    }
    })


}

export function EditRoleData(transfer) {
  return service({
    url: "/bestpaygo-user/v1/role/edit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export const getallocationadmin = (queryType,roleId,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/adminPageUsers', {
    params: {
     queryType,roleId,pageNum,pageSize
    }
  })
}
export const getallAdminlike = (nickname,phone,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/adminPageUsers', {
    params: {
     nickname,phone,pageNum,pageSize
    }
  })
}

export const getallocationdistributor = (queryType,roleId,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/distributorPageUsers', {
    params: {
     queryType,roleId,pageNum,pageSize
    }
  })
}
export const getalldistributorlike = (nickname,phone,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/distributorPageUsers', {
    params: {
     nickname,phone,pageNum,pageSize
    }
  })
}
export const getallocationenduser = (queryType,roleId,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/endPageUsers', {
    params: {
     queryType,roleId,pageNum,pageSize
    }
  })
}
export const getallenduserlike = (queryType,roleId,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/user/endPageUsers', {
    params: {
     queryType,roleId,pageNum,pageSize
    }
  })
}

export const likeyuadmin = (queryType,roleId,nickname,communication) => {
  return service.get('/bestpaygo-user/v1/user/adminPageUsers', {
    params: {
     queryType,roleId,nickname,communication
    }
  })
}
export const likeyudistributor = (queryType,roleId,nickname,communication) => {
  return service.get('/bestpaygo-user/v1/user/distributorPageUsers', {
    params: {
     queryType,roleId,nickname,communication
    }
  })
}
export const likeyuenduser = (queryType,roleId,nickname,communication) => {
  return service.get('/bestpaygo-user/v1/user/endPageUsers', {
    params: {
     queryType,roleId,nickname,communication
    }
  })
}

// device
export const equipmentType = () => {
  return service.get('/bestpaygo-iot/v1/dict/equipmentType', {
    params: {
    }
  })
}

export const endDropDownapi = () => {
  return service.get('/bestpaygo-user/v1/user/endDropDown', {
    params: {
    }
  })
}
export const getInventorydevice = (pageNum,pageSize) => {
  return service.get('/bestpaygo-iot/v1/equipment/inventoryPageEquipments', {
    params: {
      pageNum,pageSize
    }
  })
}
// equipmentName equipmentNumber equipmentType inventoryStatus timeType timevaluestorageTime
export const getInventorydevicelike = (equipmentName,equipmentNumber,agentUserId,inventoryStatus,timeType,storageTime,pageNum,pageSize) => {
  return service.get('/bestpaygo-iot/v1/equipment/inventoryPageEquipments', {
    params: {
     equipmentName,equipmentNumber,agentUserId,inventoryStatus,timeType,storageTime,pageNum,pageSize
    }
  })
}

export const getChuListDeviceApi = (pageNum,pageSize,queryType) => {
  return service.get('/bestpaygo-iot/v1/equipment/inventoryPageEquipments', {
    params: {
      pageNum,pageSize,queryType
    }
  })
}

export function inventoryOutboundDis(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/inventoryOutboundDis",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function AddInventory(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/inventoryInsert",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function updateInventory(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/inventoryEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function batchAddInventory(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/batchInventoryInsert",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function InventoryFile(formData) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/importInventoryInsert",
    method: "post",
    data: formData,
    headers: {
       'Content-Type': 'multipart/form-data'
    }
  })
}

export const delInventory = (equipmentId) => {
     return service({
      url: "/bestpaygo-iot/v1/equipment/inventoryRemove",
      method: "post",
      data: {
        equipmentId
      },
    headers: {
      'Content-Type': 'application/json'
    }
    })


}



export const getEndUserdeviceapi = (pageNum,pageSize) => {
  return service.get('/bestpaygo-iot/v1/equipment/endUserPageEquipments', {
    params: {
      pageNum,pageSize
    }
  })
}

export const getEndUserdevicelike = (equipmentName,equipmentNumber,userId,equipmentStatus,onlineStatus,timeType,sellTime,pageNum,pageSize) => {
  return service.get('/bestpaygo-iot/v1/equipment/endUserPageEquipments', {
    params: {
     equipmentName,equipmentNumber,userId,equipmentStatus,onlineStatus,timeType,sellTime,pageNum,pageSize
    }
  })
}

export function updateEndUserDevice(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/endEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getEndUserBangListapi = (pageNum,pageSize,queryType) => {
  return service.get('/bestpaygo-user/v1/user/endPageUsers', {
    params: {
     pageNum,pageSize,queryType
    }
  })
}
// export const getEndUserBangDevice = (pageNum,pageSize,queryType) => {
//   return service.get('/bestpaygo-iot/v1/equipment/endUserPageEquipments', {
//     params: {
//      pageNum,pageSize,queryType
//     }
//   })
// }

export function BangEndUser(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/inventoryBindEnd",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function editequipmentStatus(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/endEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function endReturn(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/equipment/endReturn",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getActivationapi = (pageNum,pageSize) => {
  return service.get('/bestpaygo-iot/v1/activation/equipmentRecordPages', {
    params: {
     pageNum,pageSize
    }
  })
}
export const getActivationlike = (generationStartTime,generationEndTime,expirationStatus,pageNum,pageSize) => {
  return service.get('/bestpaygo-iot/v1/activation/equipmentRecordPages', {
    params: {
     generationStartTime,generationEndTime,expirationStatus,pageNum,pageSize
    }
  })
}
export function delActivation(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/activation/activationRemove",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getcdkeypanelapi = (equipmentId) => {
  return service.get('/bestpaygo-iot/v1/activation/equipmentDetailPlan', {
    params: {
    equipmentId
    }
  })
}
export const fronttestapi = (equipmentId) => {
  return service.get('/bestpaygo-iot/v1/activation/activationGeneratePreInspection', {
    params: {
    equipmentId
    }
  })
}

export function createdurationapi(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/activation/generateDurationActivationCode",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function createtestapi(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/activation/generateTestActivationCode",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function createforeverapi(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/activation/generatePerpetualActivationCode",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function sendtextmessageapi(transfer) {
  return service({
    url: "/bestpaygo-iot/v1/activation/activationSmsSend",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}



export const getFeedbackdata = (pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/feedback/pageFeedbacks', {
    params: {
    pageNum,pageSize
    }
  })
}
export const getFeedbackdatalike = (feedbackTitle,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/feedback/pageFeedbacks', {
    params: {
    feedbackTitle,pageNum,pageSize
    }
  })
}
export function AddFeedBack(transfer) {
  return service({
    url: "/bestpaygo-user/v1/feedback/wordAdd",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getFeedbackDetail = (feedbackId) => {
  return service.get(`/bestpaygo-user/v1/feedback/feedbackDetails/${feedbackId}`, {
    params: {
    }
  })
}

export function editFeedBack(transfer) {
  return service({
    url: "/bestpaygo-user/v1/feedback/wordEdit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function delFeedback(feedbackId) {
  return service({
    url: "/bestpaygo-user/v1/feedback/wordRemove",
    method: "post",
    data: {
      feedbackId
    },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export function feedbackSubmitjiedian(transfer) {
  return service({
    url: "/bestpaygo-user/v1/progress/feedbackSubmit",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function submitauthorize(transfer) {
  return service({
    url: "/bestpaygo-user/v1/role/authorize",
    method: "post",
    data: transfer,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}


export const getOperatelogdata = (pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/log/selectPageOprlogs', {
    params: {
      pageNum,pageSize
    }
  })
}

export const getOperatedatalike = (username,optType,status,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/log/selectPageOprlogs', {
    params: {
      username,optType,status,pageNum,pageSize
    }
  })
}

export function delOperatelog(operId) {
  return service({
    url: "/bestpaygo-user/v1/log/removeOprlog",
    method: "post",
    data: {
      operId
    },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getloginlogdata = (pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/log/selectPageLogininfors', {
    params: {
      pageNum,pageSize
    }
  })
}
export const getLoginlogdatalike = (username,pageNum,pageSize) => {
  return service.get('/bestpaygo-user/v1/log/selectPageLogininfors', {
    params: {
      username,pageNum,pageSize
    }
  })
}
export function delLoginlog(loginId) {
  return service({
    url: "/bestpaygo-user/v1/log/removeLogininfor",
    method: "post",
    data: {
      loginId
    },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getstatcardListdata = () => {
  return service.get('/bestpaygo-user/v1/user/userTotalPlan', {
    params: {
    }
  })
}
export const getstatcardListDistributordata = () => {
  return service.get('/bestpaygo-iot/v1/equipment/equipmentTotalPlan', {
    params: {
    }
  })
}






